package org.custom.spring.boot.config;

import cn.hutool.core.lang.Snowflake;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.Serializable;

/**
 * 基础/默认的配置类
 *
 * @author 李坤
 * @date 2022/4/12 16:31
 */
@Configuration
public class BasicConfig implements Serializable {

    /**
     * ID 生成器
     */
    @Bean
    public Snowflake snowflake() {
        return new Snowflake(1, 1);
    }

    /**
     * MyBatis-Plus 乐观锁插件
     */
    @Bean
    public OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor() {
        return new OptimisticLockerInnerInterceptor();
    }

}
